package fr.umlv.m2.recipes.ideas.bean;

import java.io.Serializable;

/**
 * Bean uses to create a Step in the database
 * @author Christophe Chillan
 *
 */
@SuppressWarnings("serial")
public class StepBean implements Serializable {
	
	private int id;
	String name;
	private String description;
	private int duration;
	private int recipeId;

	/**
	 * Create a Step for a Recipe
	 */
	public StepBean(){}
	
	/**
	 * Create a Step for a Recipe
	 * @param name
	 * @param id
	 * @param recipeId
	 */
	public StepBean(String name, int id, int recipeId){
		this.name = name;
		this.id = id;
		this.recipeId = recipeId;
	}
	
	/**
	 * Create a Step for a Recipe
	 * @param name
	 * @param description
	 */
	public StepBean(String name, String description ){
		this.name = name;
		this.description = description;
		duration = -1;
	}
	
	/**
	 * Create a Step for a Recipe
	 * @param name
	 * @param description
	 * @param duration
	 */
	public StepBean(String name, String description, int duration){
		this(name, description);
		this.duration = duration;
	}

	/**
	 * Get the name of the step related to a recipe
	 * @return the step name stored in the database
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the name of the step
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Get the id of the step
	 * @return the id of the step stored in the database
	 */
	public int getId() {
		return id;
	}

	/**
	 * Set the id of the step
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Get the description of the step
	 * @return the description of the step
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * Set the description of the step
	 * @param description
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * Get the duration of the step in second
	 * @return integer - duration of the step in second
	 */
	public int getDuration() {
		return duration;
	}

	/**
	 * Set the duration of the step in second
	 * @param duration
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}
	
	/**
	 * Get the recipe id related to the step
	 * @return the recipe id references as foreign key in the database
	 */
	public int getRecipeId() {
		return recipeId;
	}
	
	/**
	 * Set the recipe id related to the step
	 * @param recipeId
	 */
	public void setRecipeId(int recipeId){
		this.recipeId = recipeId;
	}

	/**
	 * @see Object
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("ETAPE : ").append(name).append("\n");
		builder.append("breve description : ").append(description).append("\n");
		if(duration != -1){
			builder.append("duree : ").append(duration);
		}
		return builder.toString();
	}
}
